#include "TVector3.h"
#include "TObject.h"

class TLine3D: public TObject{
public:
	TLine3D();
	TLine3D(TVector3 p1, TVector3 p2);
	TLine3D(Float_t x1, Float_t y1, Float_t x2, Float_t y2);
	TLine3D(const TLine3D &);
	
	virtual ~TLine3D() {};
	// Destructor
		 

	inline void SetPoint1(TVector3 p1) {point1=p1;}
	inline void SetPoint2(TVector3 p2) {point2=p2;}
	inline TVector3 GetPoint1() {return point1;}
	inline TVector3 GetPoint2() {return point2;}
	void Print();

private:
	TVector3 point1;
	TVector3 point2;
};

TLine3D::TLine3D()
{

}
TLine3D::TLine3D(TVector3 p1, TVector3 p2)
{
  point1=p1;
	point2=p2;
}
TLine3D::TLine3D(Float_t x1, Float_t y1, Float_t x2, Float_t y2)
{
	point1.SetX(x1);
	point1.SetY(y1);
	point2.SetX(x2);
	point2.SetY(y2);
}
TLine3D::TLine3D(const TLine3D &L)
{
	point1=L.point1;
	point2=L.point2;
}
void TLine3D::Print()
{
	point1.Print();
	point2.Print();
}

double LineToLine(TLine3D L1, TLine3D L2) /// distance of two lines
{
	TVector3 a=L1.GetPoint2()-L1.GetPoint1();
	TVector3 b=L2.GetPoint2()-L2.GetPoint1();
	TVector3 ab=a.Cross(b);
	a.Print();
	b.Print();
	ab.Print();
	return fabs(ab.Dot(L1.GetPoint1()-L2.GetPoint1()))/sqrt(ab.Dot(ab));
}
